﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>服刑人员迁居登记</title>
<link href="/static/css/layout.css" rel="stylesheet" type="text/css" />
<link href="/static/css/cb.css" rel="stylesheet" type="text/css" />
<link href="/static/css/n.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css"
	href="/static/easyui/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="/static/easyui/themes/icon.css" />
<link rel="stylesheet" type="text/css" href="/static/easyui/demo/demo.css" />
<link rel="stylesheet" type="text/css"
	href="/static/js/laypage/skin/laypage.css" />

<script type="text/javascript" src="/static/easyui/jquery.min.js"></script>
<script src="/static/js/vue/vue.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/js/laypage/laypage.js"></script>
<script type="text/javascript" src="/static/laydate/laydate.js"></script>
</head>
<body>
	<div id="app">
		<table width="99%" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td width="1%" align="left" background="/static/images/b2.jpg"><img
					src="/static/images/b1.jpg" width="10" height="26" /></td>
				<td width="68%" background="/static/images/b2.jpg"><table width="124"
						border="0" align="left" cellpadding="0" cellspacing="0">
						<tr>
							<td width="20" align="left"><img src="/static/images/tz.gif"
								width="10" height="16" /></td>
							<td width="104" align="left" class="biao">迁居登记查询</td>
						</tr>
					</table></td>
				<td width="31%" align="right" background="/static/images/b2.jpg"><img
					src="/static/images/b3.jpg" width="9" height="26" /></td>
			</tr>
		</table>
		<table width="99%" border="0" align="center" cellpadding="3"
			cellspacing="1" bgcolor="#AEDEF4">
			<tr>
				<td align="center" bgcolor="#E2F7FE">
					<form id="form1" name="form1" method="post" action="">
						<table width="80%" border="0" cellspacing="1" cellpadding="3">
							<tr>
								<td width="10%" align="right">矫正单位:</td>
								<td width="10%" align="left">
									<select id="jid" onchange="getMovePersonel()">
										<option value="0">任意</option>
									    <#list list as jDepartment>
										   <option value="${jDepartment.id}">${jDepartment.name}</option>
									    </#list>
								    </select>
								</td>
								<td width="10%" align="right">姓 名:</td>
                                <td width="10%" align="left">
									<select id="cid" style="width:120px; height: 17px">
                                       <option value="0">任意</option>
                                       <option v-for="item in names" :value="item.id">{{item.name}}</option>
                                    </select>
								</td>
								<td width="10%" align="right">迁居日期:</td>
								<td width="10%" align="left"><input placeholder="请输入日期"
									class="laydate-icon" onclick="laydate()" id="startDate" /></td>
								<td width="10%" align="left"><input placeholder="请输入日期"
									class="laydate-icon" onclick="laydate()" id="endDate" /></td>
								<td width="10%" align="left"><input type="button"
									onclick="checkEvent()" value="查找"/></td>
								<td width="10%"  align="right">
                                    <input type="button" onclick="addCount()" value="增加记录" />
									<input type="button" onclick="deleteBut()" value="批量删除" />
								</td>
								<td width="10%"  align="right">
                                    <input type="button" onclick="exportBut()" value="批量导出" />
                                    <input type="button" onclick="exportExcel()" value="全部导出"/>
								</td>
							</tr>
						</table>
					</form>
				</td>
			</tr>
		</table>
		<table width="50%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="5"></td>
			</tr>
		</table>
		<table width="99%" border="0" align="center" cellpadding="0"
			cellspacing="0">
			<tr>
				<td width="1%" align="left" background="/static/images/b2.jpg"><img
					src="/static/images/b1.jpg" width="10" height="26" /></td>
				<td width="68%" background="/static/images/b2.jpg"><table width="124"
						border="0" align="left" cellpadding="0" cellspacing="0">
						<tr>
							<td width="20" align="left"><img src="/static/images/tz.gif"
								width="10" height="16" /></td>
							<td width="104" align="left" class="biao">迁居登记列表</td>
						</tr>
					</table></td>
				<td width="31%" align="right" background="/static/images/b2.jpg"><img
					src="/static/images/b3.jpg" width="9" height="26" /></td>
			</tr>
		</table>
		<table width="99%" border="0" align="center" cellpadding="3"
			cellspacing="1" bgcolor="#AEDEF4" style="border: 1px solid #AEDEF4">
			<tr>
				<td align="center" bgcolor="#EFFBFE"><input id="all"
					type="checkbox" /></td>
				<td width="5%" height="25" align="center" bgcolor="#EFFBFE">序号</td>
				<td align="center" bgcolor="#EFFBFE">矫正单位</td>
				<td align="center" bgcolor="#EFFBFE">服刑人员</td>
				<td align="center" bgcolor="#EFFBFE">迁居日期</td>
				<td align="center" bgcolor="#EFFBFE">迁居地</td>
				<td align="center" bgcolor="#EFFBFE">迁居事由</td>
				<td align="center" bgcolor="#EFFBFE">政治面貌</td>
				<td align="center" bgcolor="#EFFBFE">状态</td>
				<td align="center" bgcolor="#EFFBFE">管理操作</td>
			</tr>
			<tr v-for="(item,index) in result"
				onmouseout="this.style.backgroundColor='#ffffff'" bgcolor="#ffffff"
				onmouseover="this.style.backgroundColor='#E6F2FF'">
				<td align="center"><input name="check" type="checkbox" :value="item.id" /></td>
				<td height="25" align="center"><span v-text="startIndex+index"></span></td>
				<td align="center" class="t5">{{item.jname}}</td>
				<td align="center">{{item.cname}}</td>
				<td align="center">{{item.date}}</td>
				<td align="center">{{item.place}}</td>
				<td align="center">{{item.reson}}</td>
				<td align="center">{{item.c_zz_status}}</td>
				<td align="center">{{item.status}}</td>
				<td align="left">
					<div align="left" style="padding-left: 5px">
						<div align="center">
							<input type="button" @click="checkMovePersonel(item.cid)"
								value="查看" /> <input type="button"
								@click="updateMovePersonel(item.cid)" value="修改" /> <input
								type="button" @click="deleteMovePersonel(item.id)" value="删除" />
						</div>
					</div>
				</td>
			</tr>
			<tr>
				<td colspan="10" align="center">
					<div id="pagediv"></div>
				</td>
			</tr>
		</table>
		<!-- 查看外出请假条弹出框 -->
		<div id="checkDlag"></div>
		<!-- 增加工作人员弹出框 -->
		<div id="addDlag"></div>
		<!-- 修改工作人员弹出框 -->
		<div id="updateDlag"></div>
	</div>
	<script type="text/javascript">
		var app = new Vue({
			el : '#app',
			data : {
				names:[],
				result : [],
				startIndex : 1
			}
		});
        var getMovePersonel = function(){
            $.ajax({
                url:"/movePersonel/getAllCorrectedPerson",
                data:{
                    id:$('#jid').val()
                },
                success:function(result){
                    app.names = result.data;
                }
            });
        }
		var get = function(curr) {
			$.ajax({
				url : '/movePersonel/findList',
				dataType : "json",
				type : "get",
				data : {
					pageSize : 6,
					curPageNum : curr || 1,
					j_id : $('#jid').val(),
					c_id : $('#cid').val(),
					startDate : $('#startDate').val(),
					endDate : $('#endDate').val()
				},
				type : 'GET',
				dataType : 'json',
				success : function(data) {
					app.result = data.result;
					app.startIndex = (data.curPageNum - 1) * data.pageSize + 1;
					laypage({
						cont : 'pagediv', //容器。值支持id名、原生dom对象，jquery对象,
		                pages : data.totalPage, //总页数
		                first : "首页",
		                last : "尾页",
		                skip : true, //是否开启跳页
		                skin : '#5675A2',
		                curr : curr || 1, //当前页
		                jump : function(obj, first) { //触发分页后的回调
		                   if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
		                	   get(obj.curr);
		                       }
		                   }
					});
					invert();  //反选
				}
			});
		}

		//回调
		get();

		//条件查询
		var checkEvent = function() {
			get();
		}
		
		//查看详情
		var checkMovePersonel = function(id) {
			$('#checkDlag').dialog({
				title : '查看服刑人员详情',
				width : 600,
				height : 360,
				closed : false,
				cache : false,
				href : '/movePersonel/checkDetail?id=' + id,
				modal : true,
				buttons : [ {
					text : '关闭',
					handler : function() {
						$('#checkDlag').dialog('close');
					}
				} ]
			});
		}
		//修改迁居人员信息 
		var updateMovePersonel = function(id) {
			$('#updateDlag').dialog({
				title : '修改服刑人员信息 ',
				width : 600,
				height : 360,
				closed : false,
				cache : false,
				href : '/movePersonel/edit?id=' + id,
				modal : true,
				buttons : [ {
					text : '保存',
					iconCls : 'icon-ok',
					handler : function() {
						if($('#editForm').form('validate')){
							var formDate = new FormData($('#editForm')[0]);
							$.ajax({
								url : "/movePersonel/update",
								type : "post",
								dataType : "json",
								async : false,
								cache : false,
								contentType : false,
								processData : false,
								data : formDate,
								success : function(result) {
									if (result.code == 0) {
										$.messager.alert({
											title : '消息',
											msg : '修改成功!',
											icon : 'info'
										});
									};
									get();
									$('#updateDlag').dialog('close');
								}
							});
						}
					}
				}, {
					text : '关闭',
					handler : function() {
						$('#updateDlag').dialog('close');
					}
				} ]
			});
		}

		//删除迁居信息
		var deleteMovePersonel = function(id) {
			$.messager.confirm('提示框', '你确定要删除吗?', function(res) {
				if (res) {
					$.ajax({
						url : "/movePersonel/delete",
						type : "get",
						dataType : "json",
						data : {
							id : id
						},
						success : function(result) {
							if (result.code == 0) {
								$.messager.alert({
									title : '消息',
									msg : '删除成功!',
									icon : 'info'
								});
								get();
							}
						}
					});
				} else {
					// 取消删除
				}
			})
		}

		//添加迁居信息
		var addCount = function() {
			$('#addDlag').dialog({
				title : '增加迁居登记记录',
				width : 600,
				height : 360,
				closed : false,
				cache : false,
				href : '/movePersonel/preSave',
				modal : true,
				buttons : [ {
					text : '保存',
					iconCls : 'icon-ok',
					handler : function() {
						if($("#saveForm").form('validate')){
							$.ajax({
								url : "/movePersonel/save",
								type : "post",
								dataType : "json",
								async : false,
								cache : false,
								contentType : false,
								processData : false,
								data : new FormData($('#saveForm')[0]),
								success : function(result) {
									if(result.code == 0){
										$.messager.alert({
											title : '消息',
											msg : '保存成功!',
											icon : 'info'
										});
										get();
									}
									$('#addDlag').dialog('close');
								}
							});
						};
					}
				}, {
					text : '关闭',
					handler : function() {
						$('#addDlag').dialog('close');
					}
				} ]
			});
		}

		//导出excel表格
		var exportExcel = function() {
			var url = "/movePersonel/exportExcel";
			window.open(url);
		}

		//全选反选
		$(function() {
			// 复选框全选反选
			$("#all").click(function() {
				var isChecked = $(this).prop("checked");
				$("input[name='check']").prop("checked", isChecked);
			});
			//更改messager提示为中文
			$.extend($.messager.defaults, {
				ok : "确定",
				cancel : "取消"
			});
		})
		
		//批量导出
		var exportBut = function(){
			var ids=[];
			$("input[name='check']:checked").each(function(){
				ids.push($(this).val());
			})
			if(ids.length==0){
				$.messager.alert({
		            title: '消息',
		            msg: '请选择需要导出的信息!',
		            icon: 'info'
		        });
			}else{
				$.messager.confirm('提示框', '你确定要导出吗?',
				     function(res) {
				        if (res) {
				             var url = "/movePersonel/exportExcel?ids=" + ids;
				             window.open(url);
				        } else {
				             // 取消
				     	}
					})
			}
		}
		
		//批量删除
		var deleteBut = function(){
			var ids=[];
			$("input[name='check']:checked").each(function(){
				ids.push($(this).val());
			})
			if(ids.length==0){
				$.messager.alert({
		            title: '消息',
		            msg: '请选择要删除的信息!',
		            icon: 'info'
		        });
			}else{
				$.messager.confirm('提示框', '你确定要删除吗?',
				     function(res) {
				        if (res) {
				        	$.ajax({
				        		url:"/movePersonel/deleteBatch",
				        		data:{
				        			ids:ids
				        		},
				        		success:function(result){
				        			if(result.code==0){
				        				$.messager.alert({
				        		            title: '消息',
				        		            msg: '删除成功!',
				        		            icon: 'info'
				        		        });
				        				get();
				        			}
				        		}
				        	});
				        } else {
				           // 取消
				     }
				})
			}
		}
		
		//反选
	 var invert=function(){
		$("input[name='check']:checked").each(function(){
			if($(this).attr("checked",true)){
				$(this).removeAttr("checked");
			}
		})
	}
	</script>
</body>
</html>